-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Performance Hints] Implement check for existential any #84684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
This commit introduces a performance hint check that warns on the use of existential any in variable declarations, function and closure parameters and return, and typealiases.
7217eb3
to
13a5c2d
Compare
@swift-ci test |
lib/Sema/PerformanceHints.cpp
Outdated
return true; | ||
} | ||
|
||
bool visitTupleType(TupleType *TT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using TypeVisitor for this is incorrect because you're going to miss a lot of cases. For example, a nominal type might have a parent, which you're not visiting at all:
struct Outer<T> {
struct Inner {}
}
Outer<any P>.Inner
Please use Type.findIf() or Type.visit() instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #8ab27f Thanks for the example, added it as a test case.
@swift-ci test |
This commit introduces a performance hint check that warns on the use of existential any in variable declarations, function and closure parameters and return, and typealiases.